import { getAllClientCodeApi } from "@/api/common";
import baseStore from "@/store/modules/base";
import { reactive } from "vue";
export const searchItemList: Array<SuperSearch.SearchItem> = [
  {
    type: "input",
    label: "菜单名称",
    keyName: "name"
  },
  {
    type: "select",
    label: "菜单状态",
    keyName: "status",
    optConfig: {
      label: "label",
      value: "value"
    },
    options: [
      {
        label: "可见",
        value: 1
      },
      {
        label: "不可见",
        value: 0
      }
    ]
  },
  reactive({
    type: "select",
    label: "端口",
    keyName: "clientCode",
    optConfig: {
      label: "name",
      value: "code"
    },
    optionsRequest: getAllClientCodeApi,
    optReqCb: (res: any, cpt: SuperSearch.SearchItem) => {
      const { code, data } = res;
      if (code === 200) {
        cpt.options = data;
      }
    },
    options: []
  })
];

// 列表
export const tableColumn: Array<SuperTable.TableCoulmnItem | SuperTable.NestTableColumnItem> = [
  {
    field: "clientCode",
    title: "端口",
    minWidth: "120",
    formatter: ({ cellValue }: any) => {
      const { name } = baseStore.clientCodeOpts.find((t: any) => t.code === cellValue) || {};
      return name;
    }
  },
  {
    field: "name",
    title: "菜单名称",
    treeNode: true,
    minWidth: "140"
  },
  {
    field: "sort",
    title: "排序",
    minWidth: "90"
  },
  {
    field: "component",
    title: "路由名称",
    minWidth: "200"
  },
  {
    field: "path",
    title: "页面路径",
    minWidth: "180"
  },
  {
    field: "type",
    title: "菜单类型",
    minWidth: "90",
    renderSlot: "type"
  },
  {
    field: "status",
    title: "可见",
    minWidth: "120",
    renderSlot: "status"
  },
  {
    field: "permission",
    title: "权限标识",
    minWidth: "120"
  },
  {
    field: "action",
    title: "操作",
    minWidth: "180",
    renderSlot: "action"
  }
];
